<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:beans="http://www.springframework.org/schema/beans"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:security="http://www.springframework.org/schema/security"
	xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
						http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
						http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
						http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd">

	<!-- Spring Servlet 컨텍스트; 서블릿 내에서 처리되는 request에 대한 하위 기능을 정의한다. -->
	
	<!-- Spring Bean으로 자동 등록될(annotated) 컴포넌트들을 스캔한다. -->
	<context:component-scan base-package="com.nts.visionworks"/>
	
	<!-- Spring application container에 등록된 모든 Bean에 대해서 메서드 보안을 적용한다. -->
	<security:global-method-security jsr250-annotations="enabled"></security:global-method-security>
	
	<!-- Spring MVC 내에서 annotation을 활용할 수 있도록 설정한다. -->
	<annotation-driven validator="validator" conversion-service="conversionService"/>

	<!-- 동영상, 이미지, 자바스크립트 등의 리소스를 URL에 매핑한다. -->
	<resources mapping="/resources/**" location="/resources/" />
	
	<!-- annotation 핸들러 매핑을 등록한다. -->
	<beans:bean id="handlerMapping" class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping">
		<beans:property name="interceptors">
			<beans:list>
				<beans:ref bean="localeChangeInterceptor"/>
				<beans:ref bean="openSessionInViewInterceptor"/>
			</beans:list>
		</beans:property>
		<beans:property name="order" value="0"></beans:property>
	</beans:bean>
	
	<!-- Lazy Loading을 위한 인터셉터로 ORM 세션을 유지하도록 도와준다. -->
	<beans:bean id="openSessionInViewInterceptor"
		class="org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor">
		<beans:property name="sessionFactory" ref="visionworksSessionFactory"></beans:property>
		<beans:property name="singleSession" value="true"></beans:property>
	</beans:bean>
	
	<!-- Spring MVC 내에서 Tiles를 활용할 수 있도록 해준다. -->
	<beans:bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
		<beans:property name="definitions">
			<beans:list>
				<beans:value>/WEB-INF/tiles/layouts/layouts.xml</beans:value>
				<beans:value>/WEB-INF/tiles/definitions/visionworks/default.xml</beans:value>
				<beans:value>/WEB-INF/tiles/definitions/visionworks/core/security.xml</beans:value>
				<beans:value>/WEB-INF/tiles/definitions/visionworks/business/contents.xml</beans:value>
				<beans:value>/WEB-INF/tiles/definitions/visionworks/business/endpoint.xml</beans:value>
				<beans:value>/WEB-INF/tiles/definitions/visionworks/business/schedule.xml</beans:value>
			</beans:list>
		</beans:property>
	</beans:bean>
	
	<!-- Tiles 정의에 의해 view를 렌더링한다. -->
	<beans:bean id="tilesViewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
		<beans:property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView" />
		<beans:property name="order" value="0" />
	</beans:bean>
	
	<!-- 별도의 XML 파일에 정의된 view를 이용해 렌더링할 수 있도록 등록한다. -->
	<beans:bean id="xmlViewResolver"
		class="org.springframework.web.servlet.view.XmlViewResolver">
		<beans:property name="location" value="/WEB-INF/spring/visionworks/views.xml"></beans:property>
		<beans:property name="order" value="1"></beans:property>
	</beans:bean>
	
	<!-- 기본적인 View Resolver로 JSP 리소스를 이용해 view를 렌더링할 수 있다. -->
	<beans:bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<beans:property name="prefix" value="/WEB-INF/views/" />
		<beans:property name="suffix" value=".jsp" />
		<beans:property name="order" value="2" />
	</beans:bean>
	
	<!-- 사용자 정의의 Spring Bean을 선언한 Spring Bean 설정 파일을 임포트한다. -->
	<beans:import resource="persistence.xml" />
	<beans:import resource="multipart.xml" />
	<beans:import resource="conversion.xml" />
	<beans:import resource="visionworks.xml" />
	
</beans:beans>
